
//baseURL
axios.defaults.baseURL='http://pcapi-xiaotuxian-front-devtest.itheima.net'

//猜你喜欢部分

function guess_like_axios(){
    var config={
         method:'get',
         url:'/home/goods/guessLike',
         headers: { 
          'User-Agent': 'Apifox/1.0.0 (https://apifox.com)'
       }
    }
 
    axios(config)
    .then(res=>{
      var data=res.data.result.items
     //猜你喜欢
     class CreateLike{
      //构造器函数(属性挂载)
      constructor(select,data){
         this.elem=document.querySelector(select);
         this.data=data
      }
      
      //方法
      render(){
         this.data.forEach(elem=>{
            this.elem.innerHTML = this.data.map(item => `<div>
            <div><a href='../html/商品详细.html?url=/goods/?id=${item.id}' axios_url=/goods/?id=${item.id}><img src=${item.picture} alt=""><a/></div>
            <p>${item.desc}</p>
            <span>￥${item.price}</span>
           </div>`).join('');
         })
      }
   }
   
                var obj=new CreateLike('.iot_guess_like',data);
                obj.render();
    
      
    })
 }
 guess_like_axios()

 var login_text=document.querySelectorAll('.iot_photo_text>p')
 if(localStorage.getItem('logon')=='true'){
   login_text[0].innerHTML='ZYX'
   login_text[0].style.marginTop='10px'
   login_text[1].style.display='none'
 }